#include "ce_vulkan_shader.h"
#include "ce_vulkan_manager.h"

CE_VulkanShader::CE_VulkanShader(VkDevice vkdevice, std::string path) : _vertShaderModule(VK_NULL_HANDLE), _fragShaderModule(VK_NULL_HANDLE), _geomShaderModule(VK_NULL_HANDLE)
{
    std::cout << "creator " << path << " shader start..." << std::endl;
    this->_vkdevice = vkdevice;
    this->_shaderPath = path;
    this->_vertexShaderCode = CE_VulkanManager::getInstance()->readShaderFile(path + ".vert.spv");
    this->_fragShaderCode = CE_VulkanManager::getInstance()->readShaderFile(path + ".frag.spv");
    // this->_geomShaderCode = CE_VulkanManager::getInstance()->readShaderFile(path + ".geom.spv");

    this->_vertShaderModule = CE_VulkanManager::getInstance()->createShaderModule(this->_vertexShaderCode);
    this->_fragShaderModule = CE_VulkanManager::getInstance()->createShaderModule(this->_fragShaderCode);
    // this->_geomShaderModule = CE_VulkanManager::getInstance()->createShaderModule(this->_geomShaderCode);
    std::cout << "creator " << path << " shader success..." << std::endl;
}

VkShaderModule CE_VulkanShader::getVertShaderModule()
{
    return this->_vertShaderModule;
}
VkShaderModule CE_VulkanShader::getFragShaderModule()
{
    return this->_fragShaderModule;
}
VkShaderModule CE_VulkanShader::getGeomShaderModule()
{
    return this->_geomShaderModule;
}
void CE_VulkanShader::destroy()
{
    vkDestroyShaderModule(this->_vkdevice, this->_vertShaderModule, nullptr);
    vkDestroyShaderModule(this->_vkdevice, this->_fragShaderModule, nullptr);
    vkDestroyShaderModule(this->_vkdevice, this->_geomShaderModule, nullptr);
}

CE_VulkanShader::~CE_VulkanShader()
{
}